package com.krain.ddbb.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.krain.corelibrary.helper.imageloader.ImageLoader;
import com.krain.corelibrary.widget.recyleview.BaseRecyclerViewAdapter;
import com.krain.ddbb.R;
import com.krain.ddbb.entity.ServiceRmarkBean;

import java.util.List;

/**
 * Created by ex-kuangxiaomin101 on 2016-02-18.
 */
public class ServiceRemarkAdapter extends BaseRecyclerViewAdapter<ServiceRemarkAdapter.ViewHolder> {

    private List<ServiceRmarkBean> mList;
    private Context context;
    private ImageLoader mImageLoader;

    public ServiceRemarkAdapter(List<ServiceRmarkBean> mList, Context context,ImageLoader imageLoader) {
        this.mImageLoader = imageLoader;
        this.mList = mList;
        this.context = context;
    }
    public List<ServiceRmarkBean> getList(){
        return mList;
    }

    public void reflush(List<ServiceRmarkBean> mList){
        this.mList = mList;
    }


    @Override
    public ViewHolder getViewHolder(View itemView) {
        return new ViewHolder(itemView);
}

    @Override
    public View getItemView(int viewType, ViewGroup parent) {
        return LayoutInflater.from(context).inflate(R.layout.item_remark_list, parent, false);
    }

    @Override
    public Object getItem(int position) {
        return  mList.get(position);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.item_remark_name.setText(mList.get(position).getComment_user());
        mImageLoader.loadImage(context, holder.item_remark_img, mList.get(position).getComment_picture(), R.mipmap.no_pic);
        holder.item_remark_gift.setText("礼貌  " + mList.get(position).getPolite_score());
        holder.item_remark_art.setText("技术  "+mList.get(position).getTechnology_score());
        holder.item_remark_time.setText("准时  "+mList.get(position).getTime_score());
        holder.item_remark_content.setText(mList.get(position).getComment_desc());
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    public  class ViewHolder extends RecyclerView.ViewHolder {
        public TextView item_remark_name;
        public ImageView item_remark_img;
        public TextView item_remark_gift;
        public TextView item_remark_art;
        public TextView item_remark_time;
        public TextView item_remark_content;

        public ViewHolder(View itemView) {
            super(itemView);
            item_remark_name = (TextView)itemView.findViewById(R.id.item_remark_list_tv_name);
            item_remark_img = (ImageView)itemView.findViewById(R.id.item_remark_list_iv);
            item_remark_gift = (TextView)itemView.findViewById(R.id.item_remark_list_tv_gift);
            item_remark_art = (TextView)itemView.findViewById(R.id.item_remark_list_tv_art);
            item_remark_time = (TextView)itemView.findViewById(R.id.item_remark_list_tv_time);
            item_remark_content = (TextView)itemView.findViewById(R.id.item_remark_list_tv_content);
        }
    }
}
